-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SPIRV] Addition of entry-point-interfaces.ll, get_global_size.ll, layout.ll test files #151648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-backend-spir-v Author: Aadesh Premkumar (aadeshps-mcw) Changes--Test that verifies correct emission of OpEntryPoint and interface variables for SPIR-V when using multiple global constants in the kernel entry point. Full diff: https://github.com/llvm/llvm-project/pull/151648.diff 3 Files Affected:
diff --git a/llvm/test/CodeGen/SPIRV/entry-point-interfaces.ll b/llvm/test/CodeGen/SPIRV/entry-point-interfaces.ll
new file mode 100644
index 0000000000000..f1e092732558e
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/entry-point-interfaces.ll
@@ -0,0 +1,31 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+; CHECK: OpEntryPoint Kernel %[[#Func:]] "test" %[[#Interface1:]] %[[#Interface2:]] %[[#Interface3:]] %[[#Interface4:]]
+; CHECK-DAG: OpName %[[#Func]] "test"
+; CHECK-DAG: OpName %[[#Interface1]] "var"
+; CHECK-DAG: OpName %[[#Interface3]] "var2"
+; CHECK-DAG: OpName %[[#Interface2]] "var.const"
+; CHECK-DAG: OpName %[[#Interface4]] "var2.const"
+; CHECK-DAG: %[[#TypeInt:]] = OpTypeInt 32 0
+; CHECK-DAG: %[[#Const1:]] = OpConstant %[[#TypeInt]] 1
+; CHECK-DAG: %[[#Const2:]] = OpConstant %[[#TypeInt]] 3
+
+; CHECK: %[[#Interface1]] = OpVariable %[[#]] UniformConstant %[[#Const1]]
+; CHECK: %[[#Interface3]] = OpVariable %[[#]] UniformConstant %[[#Const2]]
+; CHECK: %[[#Interface2]] = OpVariable %[[#]] UniformConstant %[[#Const1]]
+; CHECK: %[[#Interface4]] = OpVariable %[[#]] UniformConstant %[[#Const2]]
+
+@var = dso_local addrspace(2) constant i32 1, align 4
+@var2 = dso_local addrspace(2) constant i32 3, align 4
+@var.const = private unnamed_addr addrspace(2) constant i32 1, align 4
+@var2.const = private unnamed_addr addrspace(2) constant i32 3, align 4
+
+define dso_local spir_kernel void @test() {
+entry:
+ %0 = load i32, ptr addrspace(2) @var.const, align 4
+ %1 = load i32, ptr addrspace(2) @var2.const, align 4
+ %mul = mul nsw i32 %0, %1
+ %mul1 = mul nsw i32 %mul, 2
+ ret void
+}
diff --git a/llvm/test/CodeGen/SPIRV/get_global_size.ll b/llvm/test/CodeGen/SPIRV/get_global_size.ll
new file mode 100644
index 0000000000000..959371a7d21e7
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/get_global_size.ll
@@ -0,0 +1,50 @@
+; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+; CHECK: %[[#int32:]] = OpTypeInt 32 0
+; CHECK: %[[#int64:]] = OpTypeInt 64 0
+; CHECK: %[[#vec3:]] = OpTypeVector %[[#int64]] 3
+; CHECK: %[[#ptr_input_vec3:]] = OpTypePointer Input %[[#vec3]]
+; CHECK: %[[#global_size_var:]] = OpVariable %[[#ptr_input_vec3]] Input
+
+; CHECK: %[[#load_gs1:]] = OpLoad %[[#vec3]] %[[#global_size_var]] Aligned 1
+; CHECK: %[[#extract3:]] = OpCompositeExtract %[[#int64]] %[[#load_gs1]] 0
+
+; CHECK: %[[#bitcast1:]] = OpBitcast %[[#]] %[[#]]
+; CHECK: %[[#load_out1:]] = OpLoad %[[#]] %[[#bitcast1]] Aligned 8
+; CHECK: %[[#gep1:]] = OpInBoundsPtrAccessChain %[[#]] %[[#load_out1]] %[[#]]
+; CHECK: OpStore %[[#gep1]] %[[#extract3]] Aligned 8
+
+; CHECK: %[[#load_param_x:]] = OpLoad %[[#int32]] %[[#]]
+; CHECK: %[[#load_gs2:]] = OpLoad %[[#vec3]] %[[#global_size_var]] Aligned 1
+; CHECK: %[[#dyn_extract:]] = OpVectorExtractDynamic %[[#int64]] %[[#load_gs2]] %[[#load_param_x]]
+; CHECK: %[[#cmp:]] = OpULessThan %[[#]] %[[#load_param_x]] %[[#]]
+; CHECK: %[[#select2:]] = OpSelect %[[#int64]] %[[#cmp]] %[[#dyn_extract]] %[[#]]
+; CHECK: %[[#bitcast2:]] = OpBitcast %[[#]] %[[#]]
+; CHECK: %[[#load_out2:]] = OpLoad %[[#]] %[[#bitcast2]] Aligned 8
+; CHECK: %[[#gep2:]] = OpInBoundsPtrAccessChain %[[#]] %[[#load_out2]] %[[#]]
+; CHECK: OpStore %[[#gep2]] %[[#select2]] Aligned 8
+
+define dso_local spir_kernel void @ggs(ptr noundef align 8 %out, i32 noundef %x) {
+entry:
+ %out.addr = alloca ptr, align 8
+ %x.addr = alloca i32, align 4
+ store ptr %out, ptr %out.addr, align 8
+ store i32 %x, ptr %x.addr, align 4
+ %call = call i64 @_Z15get_global_sizej(i32 noundef 0)
+ %0 = load ptr, ptr %out.addr, align 8
+ %arrayidx = getelementptr inbounds i64, ptr %0, i64 0
+ store i64 %call, ptr %arrayidx, align 8
+ %call1 = call i64 @_Z15get_global_sizej(i32 noundef 3)
+ %1 = load ptr, ptr %out.addr, align 8
+ %arrayidx2 = getelementptr inbounds i64, ptr %1, i64 1
+ store i64 %call1, ptr %arrayidx2, align 8
+ %2 = load i32, ptr %x.addr, align 4
+ %call3 = call i64 @_Z15get_global_sizej(i32 noundef %2)
+ %3 = load ptr, ptr %out.addr, align 8
+ %arrayidx4 = getelementptr inbounds i64, ptr %3, i64 2
+ store i64 %call3, ptr %arrayidx4, align 8
+ ret void
+}
+
+declare i64 @_Z15get_global_sizej(i32 noundef)
diff --git a/llvm/test/CodeGen/SPIRV/layout.ll b/llvm/test/CodeGen/SPIRV/layout.ll
new file mode 100644
index 0000000000000..016bf7479fb98
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/layout.ll
@@ -0,0 +1,87 @@
+; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+; CHECK: OpCapability Kernel
+; CHECK: OpCapability Addresses
+; CHECK: OpCapability GenericPointer
+; CHECK: OpCapability Int64
+; CHECK: OpCapability Int8
+; CHECK: OpCapability Linkage
+
+; CHECK: OpExtInstImport "OpenCL.std"
+; CHECK: OpMemoryModel Physical64 OpenCL
+; CHECK: OpEntryPoint Kernel %[[#]] "foo" %[[#]]
+; CHECK: OpSource OpenCL_C 200000
+
+; CHECK-DAG: OpName %[[#]]
+
+; CHECK-DAG: OpDecorate %[[#]]
+
+; CHECK: %[[TYPE_I8:[0-9]+]] = OpTypeInt 8 0
+; CHECK: %[[PTR_CW_I8:[0-9]+]] = OpTypePointer CrossWorkgroup %[[TYPE_I8]]
+; CHECK: %[[TYPE_VOID:[0-9]+]] = OpTypeVoid
+; CHECK: %[[FTYPE_BAR1:[0-9]+]] = OpTypeFunction %[[TYPE_VOID]] %[[PTR_CW_I8]]
+; CHECK: %[[TYPE_I32:[0-9]+]] = OpTypeInt 32 0
+; CHECK: %[[VEC3_I32:[0-9]+]] = OpTypeVector %[[TYPE_I32]] 3
+; CHECK: %[[FTYPE_BAR2:[0-9]+]] = OpTypeFunction %[[TYPE_VOID]] %[[PTR_CW_I8]] %[[VEC3_I32]]
+; CHECK: %[[VEC4_I32:[0-9]+]] = OpTypeVector %[[TYPE_I32]] 4
+; CHECK: %[[PTR_UC_VEC4:[0-9]+]] = OpTypePointer UniformConstant %[[VEC4_I32]]
+; CHECK: %[[PTR_GEN_I8:[0-9]+]] = OpTypePointer Generic %[[TYPE_I8]]
+; CHECK: %[[STRUCT_B:[0-9]+]] = OpTypeStruct %[[TYPE_I32]] %[[PTR_GEN_I8]]
+; CHECK: %[[STRUCT_C:[0-9]+]] = OpTypeStruct %[[TYPE_I32]] %[[STRUCT_B]]
+; CHECK: %[[STRUCT_A:[0-9]+]] = OpTypeStruct %[[TYPE_I32]] %[[STRUCT_C]]
+; CHECK: %[[TYPE_F32:[0-9]+]] = OpTypeFloat 32
+; CHECK: %[[CONST_2:[0-9]+]] = OpConstant %[[TYPE_I32]] 2
+; CHECK: %[[ARRAY_F:[0-9]+]] = OpTypeArray %[[TYPE_F32]] %[[CONST_2]]
+; CHECK: %[[ARRAY_I:[0-9]+]] = OpTypeArray %[[TYPE_I32]] %[[CONST_2]]
+; CHECK: %[[PTR_UC_VEC3:[0-9]+]] = OpTypePointer UniformConstant %[[VEC3_I32]]
+; CHECK: %[[PTR_CW_STRUCTA:[0-9]+]] = OpTypePointer CrossWorkgroup %[[STRUCT_A]]
+; CHECK: %[[PTR_UC_ARRAYF:[0-9]+]] = OpTypePointer UniformConstant %[[ARRAY_F]]
+; CHECK: %[[PTR_CW_PTR_CW_I8:[0-9]+]] = OpTypePointer CrossWorkgroup %[[PTR_CW_I8]]
+; CHECK: %[[TYPE_I64:[0-9]+]] = OpTypeInt 64 0
+; CHECK: %[[PTR_CW_ARRAYI:[0-9]+]] = OpTypePointer CrossWorkgroup %[[ARRAY_I]]
+
+; CHECK: %[[C_NULL_I32:[0-9]+]] = OpConstantNull %[[TYPE_I32]]
+; CHECK: %[[C_I64_4:[0-9]+]] = OpConstant %[[TYPE_I64]] 4
+; CHECK: %[[C_I32_1:[0-9]+]] = OpConstant %[[TYPE_I32]] 1
+; CHECK: %[[C_COMP_I32:[0-9]+]] = OpConstantComposite %[[ARRAY_I]] %[[C_I32_1]] %[[CONST_2]]
+
+; CHECK: %[[VAR_V:[0-9]+]] = OpVariable %[[PTR_CW_ARRAYI]] CrossWorkgroup %[[C_COMP_I32]]
+; CHECK: %[[SPECCONSTOP:[0-9]+]] = OpSpecConstantOp %[[PTR_CW_I8]] InBoundsPtrAccessChain %[[VAR_V]] %[[C_NULL_I32]] %[[C_I64_4]]
+; CHECK: %[[VAR_S:[0-9]+]] = OpVariable %[[PTR_CW_PTR_CW_I8]] CrossWorkgroup %[[SPECCONSTOP]]
+; CHECK: %[[NULL_F:[0-9]+]] = OpConstantNull %[[ARRAY_F]]
+; CHECK: %[[VAR_F:[0-9]+]] = OpVariable %[[PTR_UC_ARRAYF]] UniformConstant %[[NULL_F]]
+; CHECK: %[[NULL_STRUCT_A:[0-9]+]] = OpConstantNull %[[STRUCT_A]]
+; CHECK: %[[VAR_A:[0-9]+]] = OpVariable %[[PTR_CW_STRUCTA]] CrossWorkgroup %[[NULL_STRUCT_A]]
+; CHECK: %[[VAR_B:[0-9]+]] = OpVariable %[[PTR_UC_VEC3]] UniformConstant
+
+; CHECK: %[[BAR1:[0-9]+]] = OpFunction %[[TYPE_VOID]] None %[[FTYPE_BAR1]]
+; CHECK: %[[P_A1:[0-9]+]] = OpFunctionParameter %[[PTR_CW_I8]]
+; CHECK: OpFunctionEnd
+
+@v = addrspace(1) global [2 x i32] [i32 1, i32 2], align 4
+@s = addrspace(1) global ptr addrspace(1) getelementptr inbounds ([2 x i32], ptr addrspace(1) @v, i32 0, i32 1), align 4
+
+%struct.A = type { i32, %struct.C }
+%struct.C = type { i32, %struct.B }
+%struct.B = type { i32, ptr addrspace(4) }
+
+@f = addrspace(2) constant [2 x float] zeroinitializer, align 4
+@b = external addrspace(2) constant <3 x i32>
+@a = common addrspace(1) global %struct.A zeroinitializer, align 4
+
+define spir_kernel void @foo(ptr addrspace(1) %a) {
+entry:
+ call spir_func void @bar1(ptr addrspace(1) %a)
+ %loadVec4 = load <4 x i32> , ptr addrspace(2) @b
+ %extractVec = shufflevector <4 x i32> %loadVec4, <4 x i32> undef, <3 x i32> <i32 0, i32 1, i32 2>
+ call spir_func void @bar2(ptr addrspace(1) %a, <3 x i32> %extractVec)
+ ret void
+}
+
+declare spir_func void @bar1(ptr addrspace(1))
+declare spir_func void @bar2(ptr addrspace(1), <3 x i32>)
+
+!opencl.ocl.version = !{!7}
+
+!7 = !{i32 2, i32 0}
|
|
✅ With the latest revision this PR passed the undef deprecator. |
…ariables for SPIR-V when using multiple global constants in the kernel entry point. --Test that verifies code generation for get_global_size() calls. --Test that verifies SPIR-V layout and initialization of various global variables.
|
Thanks for the PR! LGTM! |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/28177 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/14677 Here is the relevant piece of the build log for the reference |
--Test that verifies correct emission of OpEntryPoint and interface variables for SPIR-V when using multiple global constants in the kernel entry point.
--Test that verifies code generation for get_global_size() calls.
--Test that verifies SPIR-V layout and initialization of various global variables.